//
//  ONFetcher.h
//  OrderNow
//
//  Created by Chickennohair on 2014/02/17.
//  Copyright (c) 2014年 Familly. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface ONFetcher : NSObject

+(NSArray*) arrayObjects:(Class) objClass fromArray:(NSArray*) arrDic;

/*!
 *  Fetch JSON data
 *   @param <data> <JSON Data>
 *   @return <callback block , with array objects and error message>
 */
+(void) fetchJsonDataFromURL:(NSString*) url
                      method:(NSString*)method
                   jsonParam:(NSString*) param
          completion:(void(^)(id jsonData, NSError *error)) callback;

/*!
 *  Fetch JSON Data from file
 *   @param <data> <JSON Data>
 *   @return <callback block , with array objects and error message>
 */
+(void) fetchJsonDataFromFile:(NSString*) fileName
                   jsonParam:(NSString*) param
                  completion:(void(^)(id jsonData, NSError *error)) callback;


/*!
 *  Returns a list of objects from DATA
 *   @param <objClass> <Object Class>
 *   @param <data> <JSON Data>
 *   @return <callback block , with array objects and error message>
 */
+(void) fetchObjects:(Class) objClass
        fromJSONData:(NSData *) data
          completion:(void(^)(NSArray *objects, NSError *error)) callback;


/*!
 *  Returns a list of objects from URL
 *   @param <url> API URL
 *   @param <objClass> <Object Class>
 *   @param <json> <Parameter json>
 *   @return <callback block , with array objects and error message>
 */
+(void)fetchObjectsFromURL:(NSString*)url
                method:(NSString*)method
              jsonParam:(NSString*)json
            objectClass:(Class) objClass
             completion:(void(^)(NSArray *objects, NSError *error)) callback;


/*!
 *  Returns a list of objects from Local file
 *   @param <fileName> file name
 *   @param <objClass> <Object Class>
 *   @param <json> <Parameter json>
 *   @return <callback block , with array objects and error message>
 */
+(void)fetchObjectsFromFile:(NSString*)fileName
                 jsonParam:(NSString*)json
               objectClass:(Class) objClass
                completion:(void(^)(NSArray *objects, NSError *error)) callback;


@end
